package com.zzl.study.nacos.logging;

import com.alibaba.nacos.client.logging.NacosLogging;
import org.springframework.boot.ConfigurableBootstrapContext;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringApplicationRunListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.Ordered;
import org.springframework.core.env.ConfigurableEnvironment;

/**
 * Nacos日志Spring Boot启动监听器
 *
 * @author: zhangzl
 * @date: 2025/7/16 16:10
 * @version: 1.0
 */
public class NacosLoggingAppRunListener implements SpringApplicationRunListener, Ordered {

    public NacosLoggingAppRunListener(SpringApplication application, String[] args) {

    }

    @Override
    public void environmentPrepared(ConfigurableBootstrapContext bootstrapContext, ConfigurableEnvironment environment) {
        NacosLogging.getInstance().loadConfiguration();
    }

    @Override
    public void contextPrepared(ConfigurableApplicationContext context) {
        NacosLogging.getInstance().loadConfiguration();
    }

    @Override
    public int getOrder() {
        return 1;
    }

}
